home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 001-100 / 001-025 / 002 / make / sys.c < prev    next >
C/C++ Source or Header  |  1995-03-17  |  1KB  |  59 lines

  1. /*
  2.  *    Routines which provide a single entry point to system routines,
  3.  *    for easier debugging and porting.
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include "make.h"
  8.  
  9. /*
  10.  *    The system calls malloc()/calloc() really return a pointer suitable
  11.  *    for use to store any object (satisfies worst case alignment
  12.  *    restrictions).  As such, it should really have been declared as
  13.  *    anything BUT "char *".
  14.  *
  15.  *    Also, this gives us the opportunity to verify that the memory
  16.  *    allocator really does align things properly.
  17.  *
  18.  *    Note that we choose to make calloc () the standard memory
  19.  *    allocator, rather than malloc (), because it has a potentially
  20.  *    bigger "bite" (total is product of two ints, rather than a
  21.  *    single int).
  22.  */
  23.  
  24. long *Calloc (nelem, elsize)
  25. unsigned int nelem;
  26. unsigned int elsize;
  27. {
  28.     extern char *calloc ();
  29.     long *newmem;
  30.     long total;
  31.     
  32.     DBUG_ENTER ("malloc");
  33.     DBUG_4 ("mem1", "allocate %u elements of %u bytes", nelem, elsize);
  34.     DBUG_3 ("mem2", "total of %ul bytes", total = nelem * elsize);
  35.     newmem = (long *) calloc (nelem, elsize);
  36.     if ((((int)newmem) % 4) != 0) {
  37.     fprintf (stderr, "urk -- Calloc screwed up!\n");
  38.     }
  39.     DBUG_3 ("mem", "allocated at %x", newmem);
  40.     DBUG_RETURN (newmem);
  41. }
  42.  
  43. #ifdef AMIGA
  44.  
  45. int system (cmd)
  46. char *cmd;
  47. {
  48.     int status = -1;
  49.     extern int Execute ();
  50.     
  51.     DBUG_ENTER ("system");
  52.     if (Execute (cmd, 0 ,0)) {
  53.     status = 0;        /* Really should get exit status! */
  54.     }
  55.     DBUG_RETURN (status);
  56. }
  57.  
  58. #endif    /* AMIGA */
  59.